hvm: Define common (across VMX and SVM) set of event types.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 31 Jul 2007 09:11:47 +0000 (10:11 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 31 Jul 2007 09:11:47 +0000 (10:11 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/svm/intr.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/intr.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/hvm.h
xen/include/asm-x86/hvm/svm/vmcb.h
xen/include/asm-x86/hvm/vmx/vmx.h

index c3a30b78e848bbc8cf8d9cfff18dd9ec3c424b60..3cedb75f304ef7e33d8adc07adf90b2f780f29d6 100644 (file)
@@ -58,7 +58,7 @@ static void svm_inject_nmi(struct vcpu *v)
 
     event.bytes = 0;
     event.fields.v = 1;
-    event.fields.type = EVENTTYPE_NMI;
+    event.fields.type = X86_EVENTTYPE_NMI;
     event.fields.vector = 2;
 
     ASSERT(vmcb->eventinj.fields.v == 0);
@@ -72,7 +72,7 @@ static void svm_inject_extint(struct vcpu *v, int vector)
 
     event.bytes = 0;
     event.fields.v = 1;
-    event.fields.type = EVENTTYPE_INTR;
+    event.fields.type = X86_EVENTTYPE_EXT_INTR;
     event.fields.vector = vector;
 
     ASSERT(vmcb->eventinj.fields.v == 0);
index 7b0ad0af396e1243aaa9e9d8d9bd7c2de9aa4679..4f632275ca594eb9c4db866cbe1dc7ffd26305d7 100644 (file)
@@ -71,8 +71,8 @@ static void *root_vmcb[NR_CPUS] __read_mostly;
 /* hardware assisted paging bits */
 extern int opt_hap_enabled;
 
-static void svm_inject_exception(struct vcpu *v, int trap, 
-                                        int ev, int error_code)
+static void svm_inject_exception(
+    struct vcpu *v, int trap, int ev, int error_code)
 {
     eventinj_t event;
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
@@ -84,7 +84,7 @@ static void svm_inject_exception(struct vcpu *v, int trap,
 
     event.bytes = 0;            
     event.fields.v = 1;
-    event.fields.type = EVENTTYPE_EXCEPTION;
+    event.fields.type = X86_EVENTTYPE_HW_EXCEPTION;
     event.fields.vector = trap;
     event.fields.ev = ev;
     event.fields.errorcode = error_code;
index fd28603f9b107ee75c94a71115607667f8f20d6c..a09d0627a84114f9f826b517b20ed02b997145d5 100644 (file)
@@ -175,7 +175,8 @@ asmlinkage void vmx_intr_assist(void)
              * Clear NMI-blocking interruptibility info if an NMI delivery
              * faulted. Re-delivery will re-set it (see SDM 3B 25.7.1.2).
              */
-            if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI )
+            if ( (idtv_info_field&INTR_INFO_INTR_TYPE_MASK) ==
+                 (X86_EVENTTYPE_NMI << 8) )
                 __vmwrite(GUEST_INTERRUPTIBILITY_INFO,
                           __vmread(GUEST_INTERRUPTIBILITY_INFO) &
                           ~VMX_INTR_SHADOW_NMI);
index b2af52a52d3ace34d173ebdae1e07859156009c3..1aff21aa227f9b1872c1551688be7646a3f66ef1 100644 (file)
@@ -2965,7 +2965,8 @@ asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs)
             vmx_inject_hw_exception(v, TRAP_page_fault, regs->error_code);
             break;
         case TRAP_nmi:
-            if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) != INTR_TYPE_NMI )
+            if ( (intr_info & INTR_INFO_INTR_TYPE_MASK) !=
+                 (X86_EVENTTYPE_NMI << 8) )
                 goto exit_and_crash;
             HVMTRACE_0D(NMI, v);
             vmx_store_cpu_guest_regs(v, regs, NULL);
index 1482f4aaa52552b5e2bdd23f94b6d4907cb0b77b..6adaedad3104ba7c214704b17b809361b0de9056 100644 (file)
@@ -323,6 +323,17 @@ static inline int hvm_event_injection_faulted(struct vcpu *v)
 /* These exceptions must always be intercepted. */
 #define HVM_TRAP_MASK (1U << TRAP_machine_check)
 
+/*
+ * x86 event types. This enumeration is valid for:
+ *  Intel VMX: {VM_ENTRY,VM_EXIT,IDT_VECTORING}_INTR_INFO[10:8]
+ *  AMD SVM: eventinj[10:8] and exitintinfo[10:8] (types 0-4 only)
+ */
+#define X86_EVENTTYPE_EXT_INTR              0    /* external interrupt */
+#define X86_EVENTTYPE_NMI                   2    /* NMI                */
+#define X86_EVENTTYPE_HW_EXCEPTION          3    /* hardware exception */
+#define X86_EVENTTYPE_SW_INTERRUPT          4    /* software interrupt */
+#define X86_EVENTTYPE_SW_EXCEPTION          6    /* software exception */
+
 static inline int hvm_cpu_up(void)
 {
     if ( hvm_funcs.cpu_up )
index afea99d7b9e2cdf1a484125fe6fd351d43498482..1400e810351c82d44c1bc5bbc76ef424c2984b8d 100644 (file)
@@ -320,14 +320,6 @@ typedef union
     } fields;
 } __attribute__ ((packed)) eventinj_t;
 
-enum EVENTTYPES
-{
-    EVENTTYPE_INTR = 0,
-    EVENTTYPE_NMI = 2,
-    EVENTTYPE_EXCEPTION = 3,
-    EVENTTYPE_SWINT = 4,
-};
-
 typedef union 
 {
     u64 bytes;
index 82938a37283aec026f5db89a7fdcdd16b8f61465..2d5670faeeb2e889799055245ec8665afbd5adbc 100644 (file)
@@ -94,11 +94,6 @@ void vmx_vlapic_msr_changed(struct vcpu *v);
 #define INTR_INFO_VALID_MASK            0x80000000      /* 31 */
 #define INTR_INFO_RESVD_BITS_MASK       0x7ffff000
 
-#define INTR_TYPE_EXT_INTR              (0 << 8)    /* external interrupt */
-#define INTR_TYPE_NMI                   (2 << 8)    /* NMI                */
-#define INTR_TYPE_HW_EXCEPTION          (3 << 8)    /* hardware exception */
-#define INTR_TYPE_SW_EXCEPTION          (6 << 8)    /* software exception */
-
 /*
  * Exit Qualifications for MOV for Control Register Access
  */
@@ -276,7 +271,7 @@ static inline void __vmx_inject_exception(
      *   VM entry]", PRM Vol. 3, 22.6.1 (Interruptibility State).
      */
 
-    intr_fields = (INTR_INFO_VALID_MASK | type | trap);
+    intr_fields = (INTR_INFO_VALID_MASK | (type<<8) | trap);
     if ( error_code != VMX_DELIVER_NO_ERROR_CODE ) {
         __vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
         intr_fields |= INTR_INFO_DELIVER_CODE_MASK;
@@ -294,18 +289,18 @@ static inline void vmx_inject_hw_exception(
     struct vcpu *v, int trap, int error_code)
 {
     v->arch.hvm_vmx.vector_injected = 1;
-    __vmx_inject_exception(v, trap, INTR_TYPE_HW_EXCEPTION, error_code);
+    __vmx_inject_exception(v, trap, X86_EVENTTYPE_HW_EXCEPTION, error_code);
 }
 
 static inline void vmx_inject_extint(struct vcpu *v, int trap)
 {
-    __vmx_inject_exception(v, trap, INTR_TYPE_EXT_INTR,
+    __vmx_inject_exception(v, trap, X86_EVENTTYPE_EXT_INTR,
                            VMX_DELIVER_NO_ERROR_CODE);
 }
 
 static inline void vmx_inject_nmi(struct vcpu *v)
 {
-    __vmx_inject_exception(v, 2, INTR_TYPE_NMI,
+    __vmx_inject_exception(v, 2, X86_EVENTTYPE_NMI,
                            VMX_DELIVER_NO_ERROR_CODE);
 }